package com.hgyc.mom.qms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hgyc.mom.qms.entity.QmsInspectionTerminalItem;
import com.hgyc.mom.qms.mapper.QmsInspectionTerminalItemMapper;
import com.hgyc.mom.qms.service.QmsInspectionTerminalItemService;
import com.hgyc.mom.qms.vo.TerminalItemVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 检测终端不良采集项目 Service业务层实现
 *
 * @author fwj
 * @since 2025-07-02
 */
@Slf4j
@Service
public class QmsInspectionTerminalItemServiceImpl extends ServiceImpl<QmsInspectionTerminalItemMapper, QmsInspectionTerminalItem> implements QmsInspectionTerminalItemService {

    @Override
    public List<QmsInspectionTerminalItem> getByParentId(Long parentId) {
        LambdaQueryWrapper<QmsInspectionTerminalItem> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(QmsInspectionTerminalItem::getTerminalId, parentId);
        return list(wrapper);
    }

    @Override
    public void deleteByParentId(Long parentId) {
        LambdaQueryWrapper<QmsInspectionTerminalItem> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(QmsInspectionTerminalItem::getTerminalId, parentId);
        remove(wrapper);
    }

    @Override
    public void deleteBatchByParentIds(List<Long> parentIds) {
        LambdaQueryWrapper<QmsInspectionTerminalItem> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(QmsInspectionTerminalItem::getTerminalId, parentIds);
        remove(wrapper);
    }

    @Override
    public List<TerminalItemVO> getByTerminalId(Long terminalId) {
        return baseMapper.getByTerminalId(terminalId);
    }
}